class Solution {
public:
    void reorderList(ListNode* head) {
      ListNode* h=head,*r=h,*p=nullptr;
      if(head==nullptr||head->next==nullptr||head->next->next==nullptr) return;
      while(r->next->next!=nullptr){
        r=r->next;
      }
      p=h->next;
      h->next=r->next;
      h=p;
      r->next->next=h;
      r->next=nullptr;
      head=h;
      reorderList(head);
    }
};
